package cn.itsource.utils;

import lombok.Data;
/*
    后台返回数据给前端时，自动将对象或集合对象，转换为json格式返回给前端
           json的转换过程，会调用对象中的get方法，如果没有get方法，会报错
        message	"No converter found for return value of type: class cn.itsource.utils.AjaxResult"
 */
@Data
public class AjaxResult {
    private boolean success = true;
    private String message = "操作成功";
    private Object data;

    public AjaxResult() {
    }

    public static AjaxResult me() {
        return new AjaxResult();
    }
    public static AjaxResult error(){
        return new AjaxResult().setSuccess(false).setMessage("操作失败");
    }

    public AjaxResult setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }
}
